

cc.Class({
    extends: cc.Component,

    properties: {
        bg1: cc.Node,
        bg2: cc.Node,
        ground1: cc.Node,
        ground2: cc.Node,
    },



    onLoad() {
        this.speed = -150;
    },

    start() {

    },

    update(dt) {
        this.bg1.x += this.speed * dt;
        this.bg2.x += this.speed * dt;
        if (this.bg1.x <= 0) {
            this.bg2.x = this.bg1.x + this.bg2.width;
        }
        if (this.bg2.x <= 0) {
            this.bg1.x = this.bg2.x + this.bg1.width;
        }


        this.ground1.x += this.speed * dt;
        this.ground2.x += this.speed * dt;
        if (this.ground1.x <= cc.winSize.width / 2) {
            this.ground2.x = this.ground1.x + this.ground2.width;

        }
        if (this.ground2.x <= cc.winSize.width / 2) {
            this.ground1.x = this.ground2.x + this.ground1.width;
        }
    },
});
